package com.ase.redislike.test;

import com.ase.redislike.config.DateSourceConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author： yuhang
 * @Date： 2021/11/8
 *
 *
 * 两种方式使用logback
 * 1.通过创建LoggerFactory实例
 * 2.通过注解 @Slf4j 的方式
 *
 */
@RestController
@RequestMapping("/hello")
@Slf4j
public class HelloController {

    @Autowired
    private final DateSourceConfig dateSourceConfig;

    public HelloController(DateSourceConfig dateSourceConfig) {
        this.dateSourceConfig = dateSourceConfig;
    }

    @RequestMapping("/say/{name}")
    public String sayHello(@PathVariable("name") String name) {
        log.info("使用注解的方式日志服务：sayHello:{}", name);
        log.debug("使用注解的方式日志服务：sayHello:{}", name);
        log.error("使用注解的方式日志服务：sayHello:{}", name);
        log.warn("使用注解的方式日志服务：sayHello:{}", name);

        log.info("id:{}",dateSourceConfig.getId());
        log.info("name:{}",dateSourceConfig.getName());
        log.info("gender:{}",dateSourceConfig.getGender());
        log.info("phone:{}",dateSourceConfig.getPhone());
        log.info("age:{}",dateSourceConfig.getAge());

        return "hello " + name;
    }
}
